package main

import (
	"fmt"
	"net"
	"net/rpc"
	"net/rpc/jsonrpc"
)

func main() {
	//// 这里不需要 rpc 进行编码 采用 json编码格式
	//conn, err := rpc.Dial("tcp", ":1234")
	//if err != nil {
	//	panic("连接失败")
	//}
	conn, err := net.Dial("tcp", ":1234")
	if err != nil {
		panic("连接失败")
	}
	var reply string
	client := rpc.NewClientWithCodec(jsonrpc.NewClientCodec(conn))
	err = client.Call("HelloService.Hello", "czc", &reply)
	if err != nil {
		panic("调用失败")
	}
	fmt.Println(reply)
}
